package pjaws.paw;

public class PawSocket {

	private int myOtherPawId;
	// private Direction myDirection;
	private String myHostname;
	private int myPort;

	/**
	 * Use this constructor if a PawSocket placeholder is needed. This is useful
	 * when you want the Pjaws application to determine what the hostname and
	 * port should be.
	 * 
	 * @param otherPawId
	 * @param d
	 */
	public PawSocket(int otherPawId) {
		myOtherPawId = otherPawId;
		//myDirection = d;
	}

	/**
	 * Use this constructor if hostname and port are defined elsewhere, as in a
	 * .paw file
	 * 
	 * @param otherPawId
	 * @param d
	 * @param hostname
	 * @param port
	 */
	public PawSocket(int otherPawId, String hostname, int port) {
		myOtherPawId = otherPawId;
		// myDirection = d;
		myHostname = hostname;
		myPort = port;
	}

	/**
	 * @return the Paw Id of the other paw connected to this message's socket.
	 */
	public int getOtherPawId() {
		return myOtherPawId;
	}

	public void setHostname(String hostname) {
		myHostname = hostname;
	}

	public String getHostname() {
		return myHostname;
	}

	public void setPort(int port) {
		myPort = port;
	}

	public int getPort() {
		return myPort;
	}

	/*
	 * public Direction getDirection(){ return myDirection; }
	 */

	/**
	 * A MASTER Paw means that the local paw maintains the socket server for
	 * this connection.
	 * 
	 * @return whether or not the local paw is the master of the socket
	 */
	/*
	 * public boolean isReceive() { return myDirection == Direction.RECEIVE; }
	 */

	/**
	 * @return [paw message id, other paw id, my role, my hostname, my port]
	 */

	public String toString() {
		/*
		 * return "[" + myOtherPawId + "," + myDirection + "," + myHostname +
		 * "," + myPort + "]";
		 */
		return "[" + myOtherPawId + "," + myHostname + "," + myPort + "]";

	}

}
